<!DOCTYPE html>
<html lang="en">
<head>
    <title>考勤个人级别</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <!-- Bootstrap 3.3.6 -->
    <link rel="stylesheet" href="/dist/plugins/bootstrap/css/bootstrap.min.css">
    <!--字体-->
    <link rel="stylesheet" href="/dist/css/font-awesome.min.css">
    <!--图标-->
    <link rel="stylesheet" href="/dist/css/ionicons.min.css">
    <!--OA主样式-->
    <link rel="stylesheet" href="/dist/css/OA.min.css?t=e9c5bb62">
    <link rel="stylesheet" href="/dist/css/skins/OA-skins.min.css?t=66b457d6">
    <style>
        .bgOne {
            color: black;
        }

        .bgTwo {
            color: red;
        }

        .bgThree {
            color: #9d9d9d;
        }
        .nav-tabs-custom {
            padding: 10px;
            margin-bottom: 0;
            box-shadow: none;
            position: relative;
            overflow: hidden;
        }
        .moduleName {
            float: left;
            height: 27px;
            line-height: 27px;
            font-size: 22px;
            width: 100px;
            text-align: center;
        }
        .lineOne{
            text-align: left;
        }
        .lineOne span {
            max-height: 20px;
            line-height: 20px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }
        .imgStyle{
            width: 300px;
            /*height: 400px;*/
        }
        .infoReport {
            display: flex;
            justify-content: flex-start;
            text-align: left;
            margin-left: 10px;
        }
        .infoReport div{
            margin:0 10px;
         }
    </style>
</head>
<body>
<section class="content" id="app" v-cloak>
    <div class="oaLoad">
        <div class="loadGif" id="areaProgress"></div>
    </div>
    <div class="nav-tabs-custom oaReportNav">
        <!-- Tabs within a box -->
        <div class="moduleName">考&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;勤</div>
        <ul class="nav nav-tabs pull-right" style="margin-bottom: 10px;" v-cloak>
            <li :class="isActive(today)?'active':''"  @click="refreshData('sign','get_signInRegion',today)"><a href="#sales-chart" data-toggle="tab">今日</a></li>
           <!-- <li :class="isActive(yesterday)?'active':''" @click="refreshData('sign','get_signInRegion',yesterday)"><a href="#sales-chart" data-toggle="tab">昨日</a></li>
-->            <!--<li :class="isActive(thisWeek)?'active':''" @click="refreshData('sign','get_signInRegion',thisWeek)"><a href="#sales-chart" data-toggle="tab">本周</a></li>-->
            <li :class="isActive(thisMonth)?'active':''" @click="refreshData('sign','get_signInRegion',thisMonth)"> <a href="#sales-chart" data-toggle="tab">本月</a></li>
            <li :class="isActive(item.time)?'active':''" v-for="(item,i) in tab"  @click="refreshData('sign','get_signInRegion',item.time)"><a href="#sales-chart" data-toggle="tab">{{i==0?"上月":item.str}}</a></li>
        </ul>
    </div>
    <div style="padding: 0 10px;background: #fff;overflow: hidden" id="signInRegion">
      <!--  <div style="width: 100%;">
            <div class="infoReport">
                <div>本月应出勤：{{sign.info.shouldCount}}</div>
                <div v-if="sign.time==today||sign.time==thisMonth">当前应出勤：{{sign.info.todayCount}}</div>
                <div>已出勤：{{sign.info.signInCount}}</div>
                <div>请假：{{sign.info.leaveCount}}</div>
                <div>缺勤：{{sign.info.absenceCount}}</div>
            </div>
        </div>-->
        <div  style="width: 100%;float:left;" class="mScrollBox">
            <table class="table table-bordered text-center table-width " >
                <thead>
                <tr>
                    <!--<th style="width: 5%;">序号</th>-->
                    <th style="width: 10%" class="tableTitle">日期</th>
                    <th style="width: 7%" class="tableTitle">出勤</th>
                    <th style="width: 10%" class="tableTitle">签到时间</th>
                    <th style="width: 28%" class="tableTitle">签到地点/请假原因</th>
                    <th style="width: 10%" class="tableTitle">签退时间</th>
                    <th style="width: 28%" class="tableTitle">签退地点</th>
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in sign.list">
                    <!--<td>{{i+1}}</td>-->
                    <td>{{(item.signDate).substr(5,10)}}</td>
                    <td>
                            <span v-if="item.signState=='0'">
                                <span v-if="sign.info.entryDate==item.signDate">入职</span>
                                <i class="fa fa-check" style="color:#349f2f;" v-else></i>
                            </span>
                        <span v-else-if="item.signState==1">
                            请假
                        </span>
                        <span v-else>
                                <i class="fa fa-close" style="color:red;"></i>
                            </span>
                    </td>
                    <td>
                        {{item.signCreateTime==" 00:00"?"-":item.signCreateTime}}
                    </td>
                    <td style="text-align: left;" class="lineOne">
                        <span v-if="item.signState=='0'" @click="openImg(item.signUrl)"
                              style="color:#228bee;cursor: pointer;">{{item.startAddress}}</span>
                        <span v-else-if="item.signState==1">{{item.startAddress}}</span>
                    </td>
                    <td>
                        {{item.signOutTime==" 00:00"?"-":item.signOutTime}}
                    </td>
                    <td style="text-align: left;color:#228bee;cursor: pointer;" class="lineOne">
                        <span v-if="item.endAddress" @click="openImg(item.signOutUrl)">{{item.endAddress}}</span>
                    </td>
                </tr>
                </tbody>
            </table>
        </div>

    </div>
    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="https://file.ggxqce.com/web/bootstrap.min.js"></script>
<!--框架已定义 JS-->
<script src="/dist/js/app_iframe.js?t=0b5caf39"></script>
<!--oa自定义  JS-->
<script src="/dist/js/oa.js?t=0c4d95a9"></script>
<script type="text/javascript" src="/dist/plugins/My97DatePicker/WdatePicker.js"></script>
<script src="https://file.ggxqce.com/web/vue.min.js"></script>
<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script type="text/javascript">
    var app = new Vue({
        el: '#app',
        data: {
            userId: $.wyui.page.urlParams.userId?$.wyui.page.urlParams.userId:getCurrentUser().userId,
            yesterday:new Date(new Date()-24*60*60*1000).Format("yyyy-MM-dd"),
            today: new Date().Format("yyyy-MM-dd"),//今天
            hour:new Date().getHours(),
            thisMonth: new Date().Format("yyyy-MM"),
            thisWeek: new Date().Format("yyyy-MM-dd") + "-w",
            frontFlag:getCurrentUser().frontFlag,
            tab:[],
            sign: {
                time: $.wyui.page.urlParams.dateTime?$.wyui.page.urlParams.dateTime:new Date().Format("yyyy-MM-dd"),
                list: [],
                info:{}
            },
        },
        methods: {
            //获取tab
            openImg:function (url) {
                top.$.dialog({
                    title: '图片详情',
                    content: 'url:/page/showImg.html?url=' + url,
                    height: 500,
                    max: true,
                    min: false,
                    lock: true
                }).max();
            },
            getTab: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");
                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.tab.push(that.insert_flg(dateTime, "-", "4"))
                }
                console.log(that.tab)
            },
            getLastEndMonth: function (beginYearMonth) {
                var strYear = parseInt(beginYearMonth.substr(0, 4), 10);
                var strMonth = parseInt(beginYearMonth.substr(4, 6), 10);
                if (strMonth - 1 == 0) {
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if (strMonth < 10) {
                    strMonth = "0" + strMonth;
                }
                var monthstr = strYear + "" + strMonth;
                return monthstr;
            },
            //格式化日期
            insert_flg: function (str, flg, sn) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                var st1 = newstr.substr(2, 2);
                var st2 = newstr.substr(5, 2);
                var newstr3=st2+"-"+st1;
                var obj = {str: newstr, time: newstr};
                return obj;
            },
            //tab中点击日期刷新对应数据
            refreshData:function (dataType,fun,time) {
                var that=this;
                that[dataType].time=time;
                that[fun]();
            },
            isActive:function (item) {
                var that=this;
                if(that.sign.time==item){
                    return true;
                }
            },
            tablesMergeCell: function (list) {
                for (field in list[0]) {
                    var k = 0;
                    while (k < list.length) {
                        list[k][field + 'span'] = 1;
                        list[k][field + 'dis'] = false;
                        for (var i = k + 1; i <= list.length - 1; i++) {
                            if (list[k][field] == list[i][field] && list[k][field] != '') {
                                list[k][field + 'span']++;
                                list[k][field + 'dis'] = false;
                                list[i][field + 'span'] = 1;
                                list[i][field + 'dis'] = true;
                            } else {
                                break;
                            }
                        }
                        k = i;
                    }
                }
                return list;
            },
            //获取签到报表-区域经理
            get_signInRegion: function () {
                var that = this;
                $.wyui.postLoadMethod(urlConfig.report.attendance.getSignInByUserId, {
                    "userId": that.userId,
                    "dateTime": that.sign.time,
                    "frontFlag":that.frontFlag
                }, function (data) {
//                    var data=trimRN2(data);
                    that.sign.info.todayCount=data.todayCount;
                    that.sign.info.shouldCount = data.shouldCount;
                    that.sign.info.signInCount = data.signInCount;
                    that.sign.info.leaveCount = data.leaveCount;
                    that.sign.info.absenceCount = data.absenceCount;
                    that.sign.info.entryDate=data.entryDate;
                },true,true);

                $.wyui.postLoadMethod(urlConfig.report.attendance.getForPersonalByUserIdAndDateTime, {
                    "userId": that.userId,
                    "dateTime": that.sign.time
                }, function (data) {
                    console.log(data);
//                    var data=trimRN2(data);
                    that.sign.list = data;
                }, false,true);
            },
        },
        mounted: function () {
            var that = this;
            //1.获取前5个月的tab数据
            this.getTab();
            this.get_signInRegion();
        }
    });
</script>

</body>
</html>